package com.sxc.OnlineStore.goods.servlet;

import com.sxc.OnlineStore.goods.dao.GoodsImp;
import com.sxc.OnlineStore.goods.domain.Goods;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/ShowGoodsServlet")
public class ShowGoodsServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        String searchInput = request.getParameter("searchInput");
        if (searchInput.equals("1")){
            //查询所有的商品
            GoodsImp goodsImp = new GoodsImp();
            ArrayList<Goods>goodsArrayList = goodsImp.QueryGoods();
            request.setAttribute("goodsArrayList",goodsArrayList);
            request.getRequestDispatcher("goods_show.jsp").forward(request,response);

        }





    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doPost(request,response);
    }
}
